package com.kool.kadmin.system.controller;

import com.kool.kadmin.common.bean.PageListResult;
import com.kool.kadmin.common.bean.Result;
import com.kool.kadmin.system.bean.SysCounterDo;
import com.kool.kadmin.system.request.AddCntReq;
import com.kool.kadmin.system.request.DeleteCntReq;
import com.kool.kadmin.system.request.GetCntPageReq;
import com.kool.kadmin.system.request.ModifyCntReq;
import com.kool.kadmin.system.service.CounterService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 计数器管理
 *
 * @author luyu
 */
@RestController
public class CounterController {
    @Resource
    private CounterService counterService;

    /**
     * 新增计数器
     *
     * @return
     */
    @RequestMapping("/cnt/add")
    public Result add(@Valid @RequestBody AddCntReq request) {
        return counterService.add(request);
    }

    /**
     * 修改计数器
     *
     * @return
     */
    @RequestMapping("/cnt/modify")
    public Result modify(@Valid @RequestBody ModifyCntReq request) {
        return counterService.modify(request);
    }

    /**
     * 删除计数器
     *
     * @return
     */
    @RequestMapping("/cnt/delete")
    public Result delete(@Valid @RequestBody DeleteCntReq request) {
        return counterService.delete(request);
    }

    /**
     * 分页查询计数器
     *
     * @return
     */
    @RequestMapping("/cnt/get_page")
    public PageListResult<SysCounterDo> getPage(@Valid @RequestBody GetCntPageReq request) {
        return counterService.getPage(request);
    }
}
